import axios from 'axios';

// 定义返回数据类型
interface ContactResponse {
  code: number;
  status: string;
  msg: string;
  data: {
    count: number;
    list: object,
  }[];
}

interface PaginationParams {
  field: any;
  page: number;
  pageSize: number;
}
interface EditParams {
  mywxid: string;
  wxid: string;
  field: object; 
}
interface EditWeixinParams {
  mywxid: string;
  field: object;  
}

interface infoParams {
  mywxid: string;
  wxid: string;  
}

interface batchdelParams {
  mywxid: string;
  wxids: Array<string>;  
}
interface batcheditParams {
  mywxid: string;
  wxids: Array<string>;  
  field: object;
}
// 获取微信列表
export function getWeChatList() {
  return axios.post('/api/update/wxlist');
}
// 获取微信明细
export function getWxInfo(wxid: string) {
  return axios.post<ContactResponse>(`/api/get/wxinfo/${wxid}`);
}
// 获取群列表
export function getGroupList(wxid: string, data: PaginationParams) {
  return axios.post<ContactResponse>(`/api/get/grouplist/${wxid}`,{data});
}
// 获取好友列表
export function getFriendList(wxid: string,data: PaginationParams) {
  return axios.post<ContactResponse>(`/api/get/friendlist/${wxid}`,{data});
}
// 获取公众号列表
export function getPublickList(wxid: string,data: PaginationParams) {
  return axios.post<ContactResponse>(`/api/get/publicklist/${wxid}`,{data});
}

// 更新群列表
export function updateGroupList(wxid: string) {
  return axios.post<ContactResponse>(`/api/update/grouplist/${wxid}`);
}
// 更新好友列表
export function updateFriendList(wxid: string) {
  return axios.post<ContactResponse>(`/api/update/friendlist/${wxid}`);
}
// 更新公众号列表
export function updatePublickList(wxid: string) {
  return axios.post<ContactResponse>(`/api/update/publicklist/${wxid}`);
}
// 修改好友字段
export function editFriend(data: EditParams) {
  return axios.post<ContactResponse>(`/api/edit/friend`,data);
}
// 修改群字段
export function editGroup(data: EditParams) {
  return axios.post<ContactResponse>(`/api/edit/group`,data);
}
// 修改群备注
export function editPublick(data: EditParams) {
  return axios.post<ContactResponse>(`/api/edit/publick`,data);
}
// 修改好友备注
export function editFriendRemark(data: EditParams) {
  return axios.post<ContactResponse>(`/api/edit/friendremark`,data);
}
// 修改微信字段
export function editWeixn(data: EditWeixinParams) {
  return axios.post<ContactResponse>(`/api/edit/weixin`,data);
}

// 批量修改好友字段
export function batchEditFriend(data: batcheditParams) {
  return axios.post<ContactResponse>(`/api/edit/batchfriends`,data);
}

// 获取好友信息
export function getFriendInfo(data: infoParams) {
  return axios.post<ContactResponse>(`/api/get/friendinfo`,data);
}

// 获取群信息
export function getGroupInfo(data: infoParams) {
  return axios.post<ContactResponse>(`/api/get/groupinfo`,data);
}
// 获取公众号信息
export function getPublickInfo(data: infoParams) {
  return axios.post<ContactResponse>(`/api/get/publickinfo`,data);
}
// 批量删除
export function BatchDelete(data: batchdelParams) {
  return axios.post<ContactResponse>(`/api/delete/friend`,data);
}
// 退出群
export function quitGroup(data: batchdelParams) {
  return axios.post<ContactResponse>(`/api/quitGroup`,data);
}

// 全部开关修改
export function batchEditFriendSwitch(data: any) {
  return axios.post<ContactResponse>(`/api/edit/batchfriendswitch`,data);
}
export function batchEditGroupSwitch(data: any) {
  return axios.post<ContactResponse>(`/api/edit/batchgroupswitch`,data);
}

// vip
export function enableVip(data: any) {
  return axios.post<ContactResponse>(`/api/enableVip`,data);
}
export function editVip(data:any) {
  return axios.post<ContactResponse>(`/api/editVip`,data);
}

export function getAccount(data: any) {
  return axios.post<ContactResponse>(`/api/getAccount`,data);
}